/*
 * Name: Joon Ho Cho
 * Date: 10/24/2008
 * Course: 15-437
 */

package scheduler.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.mybeans.dao.DAOException;

import scheduler.model.Model;
import scheduler.model.UserDao;


public class LogoutAction extends Action {

	UserDao userDao;
	public LogoutAction(Model model) {
		userDao = model.getUserDao();
	}

	public String getName() { return "logout.do"; }

	public String perform(HttpServletRequest request) {
        HttpSession session = request.getSession(false);
        session.setAttribute("user",null);
        request.setAttribute("bookmarks", null);
        session.setAttribute("bookmark", null);

		request.setAttribute("message","You are now logged out");
		try {
			request.setAttribute("registeredUsers", userDao.getAll());
		} catch (DAOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
        return "login.jsp";
    }
}
